---
category: Array
created: '2021-03-07'
title: Remove duplicate values in an array
updated: '2021-10-22'
---

**JavaScript version**

```js removeDuplicate.js
const removeDuplicate = (arr) => arr.filter((i) => arr.indexOf(i) === arr.lastIndexOf(i));
```

**TypeScript version**

```ts removeDuplicate.ts
const removeDuplicate = <T,_>(arr: T[]): T[] => arr.filter((i) => arr.indexOf(i) === arr.lastIndexOf(i));
```

**Example**

```js example.js
removeDuplicate(['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']); //  ['h', 'e', 'w', 'r', 'd']
```
